package com.sww.pj.sys.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sww.pj.common.pojo.JsonResult;
import com.sww.pj.sys.pojo.Role;
import com.sww.pj.sys.service.RoleService;

@RestController
@RequestMapping("/role/")
public class RoleController {
	
	@Autowired
	private RoleService roleService;
	@RequestMapping("doFindPageObjects")
	public JsonResult doFindPageObjects(String name,Long pageCurrent) {
		return new JsonResult(roleService.findPageObjects(name, pageCurrent));
	}
	@RequestMapping("doInsertObject")
	public JsonResult doInsertObject(Role role,Integer[] menuIds) {
		roleService.insertObject(role, menuIds);
		return new JsonResult("提交成功");
	}
	@RequestMapping("doFindObjectById")
	public JsonResult doFindObjectById(Integer id) {
		return new JsonResult(roleService.findObjectById(id));
	}
	@RequestMapping("doUpdateObject")
	public JsonResult doUpdateObject(Role role,Integer[] menuIds) {
		roleService.updateObject(role, menuIds);
		return new JsonResult("修改成功");
	}
	@RequestMapping("doDeleteObject")
	public JsonResult doDeleteObject(Integer id) {
		roleService.deleteObject(id);
		return new JsonResult("删除成功");
	}
	@RequestMapping("doFindRoles")
	public JsonResult doFindRoles() {
		return new JsonResult(roleService.findRoles());
	}
}
